<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>顶层对象的属性</title>
</head>

<body>
    <div>浏览器顶层对象是 window Node环境是 global</div>
    <div>在ES5中，顶层对象属性和全局变量等价</div>
    <pre>
    window.a = 1; //顶层对象
    let a = 2;    //全局变量
    console.log(a);   //2
  </pre
    >
  </body>
</html>
<script>
  window.a = 1; //顶层对象
  let a = 2;
  console.log(a);
</script>